<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<title>缺陷确认列表页面</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../lib/layui/css/layui.css" media="all">
<style>
  #tableWrap .layui-table-cell {
    height: auto;
  }

  #tableWrap .layui-table-box,
  #tableWrap .layui-table-body,
  #tableWrap .layui-table-cell {
    overflow: visible;
  }

  #layui-laypage-1 .layui-laypage-limits {
    display: none;
  }

  .layui-table-cell laytable-cell-1-0-0 laytable-cell-checkbox {
    display: none;
  }
</style>
</head>
<body>
<!--缺陷确认管理列表页面-->
<div style="margin-bottom: 5px;" id="bugId">

  <!--缺陷信息列表模块-->
  <table class="layui-table" lay-data="{width: 800,height:230, url:'/solver/bugInfoList', page:true,limit:3, id:'test'}" lay-filter="demo">
    <thead>
    <tr>
      <th lay-data="{type:'checkbox',fixed: 'left', width:50}"></th>
      <th lay-data="{field:'lineCode', width:90}">线路编号</th>
      <th lay-data="{field:'poleCode', width:90}">杆塔编号</th>
      <th lay-data="{field:'bugLevelName', width:90}">缺陷等级</th>
      <th lay-data="{field:'bugTypeName', width:90}">缺陷类型</th>
      <th lay-data="{field:'bugDesc', width:90}">缺陷描述</th>
      <th lay-data="{field:'discovererName', width:90}">发现人员</th>
      <th lay-data="{field:'discoverTime', width:180}">发现时间</th>
    </tr>
    </thead>
  </table>
  <div class="layui-btn-group demoTable">
    <button class="layui-btn" data-type="getCheckData">确定</button>
  </div>
</div>
<script src="../lib/layui/layui.js" charset="utf-8"></script>
<script src="../js/jquery.min.js" charset="utf-8"></script>
<script>
  layui.use('table', function () {
    var table = layui.table;

    //监听表格复选框选择
    table.on('checkbox(demo)', function (obj) {
      // console.log(obj.data)
    });
    var $ = layui.$, active = {
      getCheckData: function () { //获取选中数据
        var checkStatus = table.checkStatus('test'),
            data = checkStatus.data;
        // console.log(JSON.stringify(data));
        //修改是否分配任务
        $.ajax({
            type: "POST",
            contentType: "application/json;charset=UTF-8",
            url: "/solver/isBugAllocate" ,//url
            data: JSON.stringify(data),  //提交的数据
            success: function (result) {
              if (result = "seccess") {
                layer.msg('添加成功');
                //延迟1秒执行，目的是让用户看到提示
                setTimeout( function(){
                  parent.tools.callbackShow(data);
                  //1、先得到当前iframe层（弹出层）的索引  ///2、提交成功关闭弹出层窗口
                  var index = parent.layer.getFrameIndex(window.name);
                  parent.layer.close(index);

                  // table.reload('test', {
                  //   page: {
                  //     curr: 1 //重新从第 1 页开始
                  //   },
                  //   url: '/solver/bugInfoListStatus', //后台做模糊搜索接口路径
                  //   method: 'post'
                  // });
                  // parent.tools.callbackShow(data);
                }, 1 * 1000 );
              };
            },
            error : function() {
              layer.msg('后台异常！未添加成功');
            }
          });

        // parent.tools.callbackShow(data);
        // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        // parent.layer.close(index); //再执行关闭
      }
    };


    $('.demoTable .layui-btn').on('click', function () {
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
</script>

</body>
</html>